package uc.org.jkas.app.admin;
import java.util.HashMap;
import java.util.Map.Entry;
import org.jkas.core.Base;
public class ScBackBase extends Base
{  protected final static String JSON_RESULT_FAILED="{\"code\":400,\"msg\":\"failed\"}";
   protected final static String JSON_RESULT_SUCCESS="{\"code\":200,\"msg\":\"ok\"}";
   protected final static String SYS_VERSION="1.0.0";
   protected final static int SYS_VERCODE=1;
   protected final static String SYS_NAME="SoonecUcenter";
   public boolean init()
	{
	 viewPath("themes");
	 viewTheme("default");
	 this.viewInit();
     this.localeInit();
	 this.assign("L",this.lang());
	 this.assign("__images__",this.viewPath()+"/"+this.viewTheme()+"/images");
	 assign("app",this.getApp().toLowerCase());
	 assign("locale",cookie("locale"));
	 assign("sys_version",SYS_VERSION);
	 assign("sys_vercode",SYS_VERCODE);
	 assign("sys_name",SYS_NAME);
	 return true;
	}

	protected final void imports(HashMap<String,String> res)
	{StringBuilder str=new StringBuilder();
	   int index=0;
	   for(Entry<String, String> item :res.entrySet())
		{String key=item.getKey();
         String[] value=item.getValue().split(",");
          int len=value.length;
		  if(index>0)
			{str.append("\n");
			}
		  for(int i=0;i<len;i++)
			{ if(i>0)
			    {str.append("\n");
				}
			  str.append(imports(key,value[i]));
			}
			index++;
		}
	 assign("__header_str__",str.toString());
	 str=null;
	}

	protected final void imports(String ...res)
	{StringBuilder str=new StringBuilder();
	   int index=0;
	   for(int i=0;i<res.length;i++){
		    if(res[i].endsWith(".css"))
		     {str.append(imports("css",res[i]));
		     }
			 else if(res[i].endsWith(".js"))
		     {str.append(imports("js",res[i]));
		     }
			 else if(res[i].endsWith(".rescss"))
		     {str.append(imports("rescss",res[i].replace(".rescss",".css")));
		     }
			 else if(res[i].endsWith(".resjs"))
		     {str.append(imports("resjs",res[i].replace(".resjs",".js")));
		     }
	     }
	 assign("__header_str__",str.toString());
	 str=null;
	}

	protected final void seo(String title,String description,String keywords)
	{assign("page_title",title);
	 assign("page_keywords",keywords);
	 assign("page_description",description);
	}
}